Use the code below to re-define the standardize() function and to create a vector with standardized numbers.

standardize <- function (x) {
  (x - mean(x, na.rm = TRUE)) / sd(x, na.rm = TRUE)
}

standardized_vector <-
  standardize(sample(1:100, 30))

1

Loop through each element of the vector and add the number pi using a for()-loop.
There’s a pre-defined value in R for pi. Just type pi and you’ll receive 3.141593. Also, you need to wrap everything within the print() function.

2

Repeat the previous exercise but this time the results should be printed all at once in a vector. You would need the sapply() function for that.
You don’t need the print() function anymore.

3

Now, we want to have the same output as a list. What’s your approach on doing this?
You can either use lapply() or purrr::map.